#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 1e5+10;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}

struct node
{
	ll l;
	ll r;
}lm[maxn];
ll ans[maxn];
int main()
{
	ll t;
	t = read();
	while(t--)
	{
		ll n,k;
		n = read();
		k = read();
		for(int i = 1;i<=n;i++)
		{
			lm[i].l = read();
			lm[i].r = read();
		}
		lm[1].l -= k;
		lm[1].r += k;
		int flag;
		for(int i = 2;i<=n;i++)
		{
			flag = 0;
			if(lm[i].l>=lm[i-1].l&&lm[i].r<=lm[i-1].r)
			{
				flag = 1;
				lm[i].l -= k;
				lm[i].r += k;
			}
			else if(lm[i].l<=lm[i-1].l&&lm[i].r>=lm[i-1].l)
			{
				flag = 1;
				lm[i].l = lm[i-1].l-k;
				lm[i].r = min(lm[i-1].r,lm[i].r)+k;
			}
			else if(lm[i].l<=lm[i-1].r&&lm[i].r>=lm[i-1].r)
			{
				flag = 1;
				lm[i].l = max(lm[i-1].l,lm[i].l) -k;
				lm[i].r = lm[i-1].r+k;
			}
			if(!flag) break;
		}
		if(!flag) printf("NO\n");
		else 
		{
			printf("YES\n");
			for(int i = 1;i<=n;i++) printf("***%lld %lld\n",lm[i].l+k,lm[i].r-k);
			ans[n] = lm[n].l+k;
			for(int i = n-1;i>=1;i--)
			{
				ll t1 = ans[i+1]-k;
				ll t2 = ans[i+1]+k;
				ll t3 = ans[i+1];
				if(t1>=lm[i].l+k&&t1<=lm[i].r-k) ans[i] = t1;
				else if(t2>=lm[i].l+k&&t2<=lm[i].r-k) ans[i] = t2;
				else if(t3>=lm[i].l+k&&t3<=lm[i].r-k) ans[i] = t3;
			}
			printf("%d",ans[1]);
			for(int i = 2;i<=n;i++) printf(" %d",ans[i]);
			printf("\n");
		}
	}
} 
